using System.Linq;
using UnityEngine;
using UnityEngine.UI;

namespace MaterialUI
{
	public class CircleProgressIndicatorInstantiationHelper : InstantiationHelper
	{
		public const int optionRaised = 0;

		public const int optionHasLabel = 1;

		public const int optionLayoutHorizontal = 2;

		public const int optionLayoutVertical = 3;

		[SerializeField]
		private GameObject m_Shadow;

		[SerializeField]
		private GameObject m_BackgroundImage;

		[SerializeField]
		private GameObject m_Label;

		[SerializeField]
		private LayoutGroup m_LayoutGroup;

		[SerializeField]
		private ProgressIndicator m_ProgressIndicator;

		public override void HelpInstantiate(int[] options)
		{
			if (!options.Contains(0))
			{
				UnityEngine.Object.DestroyImmediate(m_Shadow);
				UnityEngine.Object.DestroyImmediate(m_BackgroundImage);
			}
			if (!options.Contains(1))
			{
				UnityEngine.Object.DestroyImmediate(m_Label);
			}
			if (!options.Contains(2) && !options.Contains(3))
			{
				base.transform.SetParent(m_LayoutGroup.transform.parent, worldPositionStays: true);
				UnityEngine.Object.DestroyImmediate(m_LayoutGroup.gameObject);
				m_ProgressIndicator.baseObjectOverride = null;
			}
			else
			{
				if (options.Contains(2))
				{
					GameObject gameObject = m_LayoutGroup.gameObject;
					UnityEngine.Object.DestroyImmediate(m_LayoutGroup);
					m_LayoutGroup = gameObject.AddComponent<HorizontalLayoutGroup>();
					m_LayoutGroup.childAlignment = TextAnchor.MiddleCenter;
					((HorizontalLayoutGroup)m_LayoutGroup).childForceExpandWidth = false;
					((HorizontalLayoutGroup)m_LayoutGroup).childForceExpandHeight = false;
				}
				if (options.Contains(0))
				{
					if (options.Contains(2))
					{
						((HorizontalLayoutGroup)m_LayoutGroup).spacing = 16f;
					}
					else if (options.Contains(3))
					{
						((VerticalLayoutGroup)m_LayoutGroup).spacing = 16f;
					}
				}
			}
			base.HelpInstantiate(options);
		}
	}
}
